/*
 *  Author: Honrun
 */
#ifndef _DevicesQueue_H_
#define _DevicesQueue_H_


#define QUEUE_MAX_LENGTH            256

#define QUEUE_UART1_READ_LENGTH     256
#define QUEUE_UART2_READ_LENGTH     256
#define QUEUE_UART3_READ_LENGTH     256
#define QUEUE_CI24R1_READ_LENGTH    256
#define QUEUE_USB_PD_READ_LENGTH    (30 * 8)
#define QUEUE_KEY_INPUT_LENGTH      128


typedef enum {
    queueNormal = 0,
    queueError,
    queueNull,
    queueEmpty,
    queueFull,
}enumQueueState;

typedef enum {
    queueModeNormal = 0,    /* 覆盖模式 */
    queueModeLock,          /* 锁定模式 */
}enumQueueMode;


typedef struct{
    char *name;

    uint8_t *buff;
    uint32_t length;
    uint32_t in;
    uint32_t out;

    enumQueueMode mode;
}QueueType;


extern QueueType g_TypeQueueUart1Read;
extern QueueType g_TypeQueueUart2Read;
extern QueueType g_TypeQueueUart3Read;
extern QueueType g_TypeQueueCi24R1Read;
extern QueueType g_TypeQueueUsbPdRead;
extern QueueType g_TypeQueueKeyInput;


enumQueueState enumQueueInit(void);
enumQueueState enumQueueCreate(QueueType *ptypeQueue, char *pcName, uint8_t *pucBuff, int32_t iLength, enumQueueMode enumMode);
enumQueueState enumQueueSetState(QueueType *ptypeQueue, enumQueueState enumState);
int32_t iQueueGetLength(QueueType *ptypeQueue);
int32_t iQueueGetLengthNeed(QueueType *ptypeQueue, uint8_t ucByte);
int32_t iQueueGetLengthSeparetor(QueueType *ptypeQueue, uint8_t ucByte);
int32_t iQueueGetLengthFree(QueueType *ptypeQueue);
enumQueueState enumQueuePushByte(QueueType *ptypeQueue, uint8_t ucByte);
enumQueueState enumQueuePopByte(QueueType *ptypeQueue, uint8_t *pucBuff);
enumQueueState enumQueueViewByte(QueueType *ptypeQueue, uint8_t *pucBuff);
enumQueueState enumQueuePushDatas(QueueType *ptypeQueue, void *pvBuff, int32_t iLength);
enumQueueState enumQueuePopDatas(QueueType *ptypeQueue, void *pvBuff, int32_t iLength);
enumQueueState enumQueueViewDatas(QueueType *ptypeQueue, void *pvBuff, int32_t iLength);
enumQueueState enumQueuePopDatasNeed(QueueType *ptypeQueue, void *pvBuff, int32_t iLength, uint8_t ucByte);
enumQueueState enumQueueViewDatasNeed(QueueType *ptypeQueue, void *pvBuff, int32_t iLength, uint8_t ucByte);


#endif
